import * as echarts from 'echarts/core';
import { BarChart, LineChart, PieChart } from 'echarts/charts'; // 按需添加图表类型
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent
} from 'echarts/components';
import { LabelLayout, UniversalTransition } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';

// 按需注册组件
export function initECharts() {
  echarts.use([
    // 图表类型
    BarChart,
    LineChart,
    PieChart,

    // 功能组件
    TitleComponent,
    TooltipComponent,
    LegendComponent,
    GridComponent,
    DatasetComponent,
    TransformComponent,

    // 扩展功能
    LabelLayout,
    UniversalTransition,

    // 渲染器
    CanvasRenderer
  ]);

  return echarts;
}

// 默认导出初始化后的 echarts 实例
export default initECharts();
